package desktop.playerguide.toolbar;

import pulpcore.image.CoreImage;
import pulpcore.sprite.Button;
import pulpcore.sprite.Group;
import pulpcore.sprite.ImageSprite;

public class ToolBar extends Group {
	CoreImage background;
	Button speedFu;

	Button backtolife;
	Button tortoiseCard;
	private int timeOfTortoiseCardClicked = 0;
	Button drasticmeasure;
	Button bomb;
	double size;

	public ToolBar(double x, double y, double w, double h) {
		super(x, y, w, h);
		size = 20.0;
		background = CoreImage.load("toolBarBackground.jpg");
		ImageSprite im = new ImageSprite(background, 0, 0, w, h);
		add(im);

		// CoreImage[] speedFuArray = new CoreImage[3];
		// for (int i = 0; i < speedFuArray.length; i++) {
		// CoreImage temp = CoreImage.load("speedFu" + i + ".jpg");
		// temp.scale(size);
		// speedFuArray[i] = CoreImage.load("speedFu" + i + ".jpg");
		// }
		// speedFu = new Button(speedFuArray, 5, h * 0.2);
		// add(speedFu);

		// CoreImage[] backtolifeArray = new CoreImage[3];
		// for (int i = 0; i < backtolifeArray.length; i++) {
		// CoreImage temp = CoreImage.load("backtolife" + i + ".jpg");
		// temp.scale(size);
		// backtolifeArray[i] = CoreImage.load("backtolife" + i + ".jpg");
		// }
		// backtolife = new Button(backtolifeArray ,0,0);
		// add(backtolife);

		CoreImage[] tortoiseCardArray = new CoreImage[3];
		for (int i = 0; i < tortoiseCardArray.length; i++) {
			CoreImage temp = CoreImage.load("tortoiseCard" + i + ".jpg");
			temp.scale(size);
			tortoiseCardArray[i] = temp;
		}
		tortoiseCard = new Button(tortoiseCardArray, 0, 0);
		tortoiseCard.setLocation(
				(this.width.get() - tortoiseCard.width.get()) / 2, (this.height
						.get() - tortoiseCard.height.get()) / 2);
		add(tortoiseCard);
		//		
		// CoreImage[] bombArray = new CoreImage[3];
		// for (int i = 0; i < bombArray.length; i++) {
		// CoreImage temp = CoreImage.load("bomb" + i + ".jpg");
		// temp.scale(size);
		// bombArray[i] = CoreImage.load("bomb" + i + ".jpg");
		// }
		// bomb = new Button(bombArray,0,0);
		// add(bomb);
		//		
		// CoreImage[] drasticmeasureArray = new CoreImage[3];
		// for (int i = 0; i < drasticmeasureArray.length; i++) {
		// CoreImage temp = CoreImage.load("drasticmeasure" + i + ".jpg");
		// temp.scale(size);
		// bombArray[i] = CoreImage.load("drasticmeasure" + i + ".jpg");
		// }
		// drasticmeasure = new Button(drasticmeasureArray, 0, 0);
		// add(drasticmeasure);
	}

	@Override
	public void update(int elapsedTime) {
		super.update(elapsedTime);
		if (tortoiseCard.isClicked()) {
			this.timeOfTortoiseCardClicked++;
			tortoiseCard.enabled.set(false);
		}
	}

	public boolean isTortoiseCardClicked() {
		return this.timeOfTortoiseCardClicked > 0;
	}

	public void tortoiseCardClickedPerformed() {
		this.timeOfTortoiseCardClicked--;
	}

}
